
#!/usr/bin/bash

# data_dir
datadir=/nexus-data

log "set mem size"
if mdata-get mem_xms 1>/dev/null 2>&1; then
    MEMXMS=`mdata-get mem_xms`
    gsed -i "s|2703m|${MEMXMS}|g" /opt/nexus/bin/nexus.vmoptions
fi

log "force correct ownership of /nexus-data directory"
chown -R nexus:nexus ${datadir}

# replace data_dir
gsed -i "s|\.\./sonatype-work/nexus3|${datadir}|" /opt/nexus/bin/nexus.vmoptions

log "starting nexus"
/usr/sbin/svcadm enable nexus
